﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using UBCon.Ribbon.Interfaces;

namespace UBCon.Ribbon
{
    [TemplatePart(Name=GroupBoxPanelName, Type=typeof(Panel))]
    public sealed class GroupBox : ItemsControl, IRibbonControl
    {
        #region Constructors

        static GroupBox()
        {

            GroupBox.DefaultStyleKeyProperty.OverrideMetadata
                (
                    typeof(GroupBox),
                    new System.Windows.FrameworkPropertyMetadata(typeof(GroupBox))
                );
        }

        public GroupBox():base()
        {
        }

        #endregion

        #region Properties and Depenency Properties

        public Orientation Orientation
        {
            get { return (Orientation)GetValue(OrientationProperty); }
            set { SetValue(OrientationProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Orientation.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty OrientationProperty =
            DependencyProperty.Register("Orientation", typeof(Orientation), typeof(GroupBox), new FrameworkPropertyMetadata(Orientation.Horizontal));

        public CornerRadius CornerRadius
        {
            get { return (CornerRadius)GetValue(CornerRadiusProperty); }
            set { SetValue(CornerRadiusProperty, value); }
        }

        // Using a DependencyProperty as the backing store for CornerRadius.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty CornerRadiusProperty = Border.CornerRadiusProperty.AddOwner(typeof(GroupBox));

        #endregion

        #region Depenency Property Changed Callbacks
        #endregion

        #region Overrides

        public override void OnApplyTemplate()
        {
            this.ItemsHost = GetTemplateChild(GroupBoxPanelName) as Panel;
            base.OnApplyTemplate();
        }
        #endregion

        #region Private Utilities
        #endregion

        #region Event Handlers
        #endregion

        #region Fields
        private const string GroupBoxPanelName = "PART_GroupBoxPanel";

        private Panel ItemsHost;

        #endregion

        #region IRibbonControl Implementation

        /// <summary>
        /// Gets a boolean value indicating whether the contol's size is large
        /// </summary>
        public bool IsLarge
        {
            get { return Orientation == System.Windows.Controls.Orientation.Vertical; }
        }

        #endregion

        
    }
}
